// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import QtMobility.gallery 1.1
import com.nokia.meego 1.0

Dialog {
    id: imageDialog
    property variant source: ""
    content:GridView{
        id: imgview
        width:  480//appWindow.width
        height: 854//appWindow.height
        anchors.centerIn: parent
        /*contentWidth: parent.width+100
        contentHeight: height+100*/
        cellWidth: 160
        cellHeight: 160
        highlight: Rectangle { color: "lightsteelblue"; radius: 5 }

        model: DocumentGalleryModel {
            id: imagemodel
            rootType: DocumentGallery.Image
            properties: [ "url" ]
            filter: GalleryWildcardFilter {
                property: "fileName";
                value: "*.jpg";
            }

        }

        delegate: Image{
            id: img
            source: isSimulator ? url : "file:///home/user/.thumbnails/grid/" +  Qt.md5(url) + ".jpeg"
            height: 160
            width: 160
            MouseArea {
                id: mouseArea
                anchors.fill: parent
                onClicked: {
                    imageDialog.source=source
                    imageDialog.accept()
                }

            }
        }       
    }
}
